[FORMAT "WCOFF"]
[INSTRSET "i486p"]
[OPTIMIZE 1]
[OPTION 1]
[BITS 32]
	EXTERN	_io_out8
	EXTERN	_io_in8
	EXTERN	_fifo32_put
	EXTERN	_wait_KBC_sendready
[FILE "mouse.c"]
[SECTION .text]
	GLOBAL	_inthandler2c
_inthandler2c:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	100
	PUSH	160
	CALL	_io_out8
	PUSH	98
	PUSH	32
	CALL	_io_out8
	PUSH	96
	CALL	_io_in8
	ADD	EAX,DWORD [_mousedata0]
	PUSH	EAX
	PUSH	DWORD [_mousefifo]
	CALL	_fifo32_put
	LEAVE
	RET
	GLOBAL	_enable_mouse
_enable_mouse:
	PUSH	EBP
	MOV	EBP,ESP
	MOV	EAX,DWORD [8+EBP]
	MOV	DWORD [_mousefifo],EAX
	MOV	EAX,DWORD [12+EBP]
	MOV	DWORD [_mousedata0],EAX
	CALL	_wait_KBC_sendready
	PUSH	212
	PUSH	100
	CALL	_io_out8
	CALL	_wait_KBC_sendready
	PUSH	244
	PUSH	96
	CALL	_io_out8
	MOV	EAX,DWORD [16+EBP]
	MOV	BYTE [3+EAX],0
	LEAVE
	RET
	GLOBAL	_mouse_decode
_mouse_decode:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	ESI
	PUSH	EBX
	MOV	EDX,DWORD [8+EBP]
	MOV	ECX,DWORD [12+EBP]
	MOV	ESI,ECX
	MOV	AL,BYTE [3+EDX]
	TEST	AL,AL
	JNE	L4
	CMP	CL,-6
	JE	L13
L12:
	XOR	EAX,EAX
L3:
	POP	EBX
	POP	ESI
	POP	EBP
	RET
L13:
	MOV	BYTE [3+EDX],1
	JMP	L12
L4:
	CMP	AL,1
	JE	L14
	CMP	AL,2
	JE	L15
	CMP	AL,3
	JE	L16
	OR	EAX,-1
	JMP	L3
L16:
	MOV	BL,BYTE [EDX]
	AND	ESI,255
	MOV	EAX,EBX
	MOV	BYTE [2+EDX],CL
	AND	EAX,7
	MOV	DWORD [8+EDX],ESI
	MOV	DWORD [12+EDX],EAX
	MOV	AL,BL
	MOVZX	ECX,BYTE [1+EDX]
	AND	EAX,16
	MOV	DWORD [4+EDX],ECX
	MOV	BYTE [3+EDX],1
	TEST	AL,AL
	JE	L10
	OR	ECX,-256
	MOV	DWORD [4+EDX],ECX
L10:
	AND	EBX,32
	TEST	BL,BL
	JE	L11
	OR	DWORD [8+EDX],-256
L11:
	NEG	DWORD [8+EDX]
	MOV	EAX,1
	JMP	L3
L15:
	MOV	BYTE [1+EDX],CL
	MOV	BYTE [3+EDX],3
	JMP	L12
L14:
	AND	ESI,-56
	MOV	EAX,ESI
	CMP	AL,8
	JNE	L12
	MOV	BYTE [EDX],CL
	MOV	BYTE [3+EDX],2
	JMP	L12
	GLOBAL	_mousefifo
[SECTION .data]
	ALIGNB	4
_mousefifo:
	RESB	4
	GLOBAL	_mousedata0
[SECTION .data]
	ALIGNB	4
_mousedata0:
	RESB	4
